package com.yuerlive.rainbow.nim;


import android.graphics.Bitmap;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by admin on 2016/9/24.
 */
public class GiftAttachment extends CustomAttachment {
    String giftNum ;
    String giftID;
    String giftName ;
    String senderName;
    String senderID;
    String giftShowImage;
    Bitmap giftBitmap;
    int  giftType ;//礼物类型  1 普通礼物 2 连击礼物 3 飘屏礼物
    String headIcon; //发送者头像

    public String getHeadIcon() {
        return headIcon;
    }

    public void setHeadIcon(String headIcon) {
        this.headIcon = headIcon;
    }

    public int getGiftType() {
        return giftType;
    }

    public void setGiftType(int giftType) {
        this.giftType = giftType;
    }

    public Bitmap getGiftBitmap() {
        return giftBitmap;
    }

    public void setGiftBitmap(Bitmap giftBitmap) {
        this.giftBitmap = giftBitmap;
    }

    public GiftAttachment() {
        super(CustomAttachmentType.GIFT);
    }

    @Override
    public String toString() {
        return "GiftAttachment{" +
                "giftNum='" + giftNum + '\'' +
                ", giftID='" + giftID + '\'' +
                ", giftName='" + giftName + '\'' +
                ", senderName='" + senderName + '\'' +
                ", senderID='" + senderID + '\'' +
                ", giftShowImage='" + giftShowImage + '\'' +
                ", giftBitmap=" + giftBitmap +
                ", giftType=" + giftType +
                ", headIcon='" + headIcon + '\'' +
                '}';
    }

    @Override
    protected void parseData(JSONObject data) {
        try {
            if(data.has("giftNum")) {
                giftNum = data.getString("giftNum");
            }
            if(data.has("giftID")) {
                giftID = data.getString("giftID");
            }
            if(data.has("giftName")) {
                giftName = data.getString("giftName");
            }
            if(data.has("senderName")) {
                senderName = data.getString("senderName");
            }
            if(data.has("senderID")) {
                senderID = data.getString("senderID");
            }
            if(data.has("giftShowImage")) {
                giftShowImage = data.getString("giftShowImage");
            }
            if(data.has("giftType")) {
                giftType = data.getInt("giftType");
            }
            if(data.has("headIcon")){
                headIcon=data.getString("headIcon");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        try {
            data.put("giftNum",giftNum);
            data.put("giftID",giftID);
            data.put("giftName",giftName);
            data.put("senderName",senderName);
            data.put("senderID",senderID);
            data.put("giftShowImage",giftShowImage);
            data.put("giftType",giftType);
            data.put("headIcon",headIcon);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return data;
    }

    public String getGiftNum() {
        return giftNum;
    }

    public void setGiftNum(String giftNum) {
        this.giftNum = giftNum;
    }

    public String getGiftID() {
        return giftID;
    }

    public void setGiftID(String giftID) {
        this.giftID = giftID;
    }

    public String getGiftName() {
        return giftName;
    }

    public void setGiftName(String giftName) {
        this.giftName = giftName;
    }

    public String getSenderName() {
        return senderName;
    }

    public void setSenderName(String senderName) {
        this.senderName = senderName;
    }

    public String getSenderID() {
        return senderID;
    }

    public void setSenderID(String senderID) {
        this.senderID = senderID;
    }

    public String getGiftShowImage() {
        return giftShowImage;
    }

    public void setGiftShowImage(String giftShowImage) {
        this.giftShowImage = giftShowImage;
    }
}
